package com.banter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class HomePage extends Activity implements OnClickListener {
	
	private Button m_createButton;
	private Button m_findButton;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_home_page);
		initLayout();
		m_createButton.setOnClickListener(this);
		m_findButton.setOnClickListener(this);
		
		BanterLocationListener gps = new BanterLocationListener(HomePage.this);
		if(!gps.canGetLocation()){
			gps.showSettingsAlert();
		}
		
	}
	
	protected void initLayout(){
    	m_createButton = (Button) this.findViewById(R.id.Create);
        m_findButton = (Button) this.findViewById(R.id.Find);
    }
	
    public void onClick(View v){
    	if(v.getId() == m_createButton.getId()){
    		Intent myCreateIntent = new Intent(HomePage.this, CreateBanter.class);
    		HomePage.this.startActivity(myCreateIntent);
    	}
    	else if (v.getId() == m_findButton.getId()){
    		Intent myFindIntent = new Intent(HomePage.this, FindBanter.class);
    		HomePage.this.startActivity(myFindIntent);
    	}
    
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_home_page, menu);
		return true;
	}

}
